package vy.org.app.common;

import java.security.KeyException;
import java.text.SimpleDateFormat;
import java.util.Date;

import org.vy.dal.dao.VyDabbaSubscriptionDO;
import org.vy.dal.seq.DabbaSubscriptionSeqGenerator;

public class DabbaIdGenerator {
	private static SimpleDateFormat DATE_FMT = new SimpleDateFormat("MMddyyyy");
	
	public static String generateId(VyDabbaSubscriptionDO subDO, String country, String stateOrRegion) throws KeyException{

		if(country == null || stateOrRegion == null)
			throw new KeyException("Required information is missing to generate key");

		String id = DabbaSubscriptionSeqGenerator.getInstance().getNextSequence();
		
		id += "/" + DATE_FMT.format(new Date()) 
			+ "/" + country 
			+ "/" + stateOrRegion;
		return id;
	}
}
